<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>AWTK-JAVA: awtk.Emitter类 参考</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">AWTK-JAVA
   </div>
   <div id="projectbrief">AWTK JAVA API</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>awtk</b></li><li class="navelem"><a class="el" href="classawtk_1_1_emitter.html">Emitter</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public 成员函数</a> &#124;
<a href="#pub-static-methods">静态 Public 成员函数</a> &#124;
<a href="#pub-attribs">Public 属性</a> &#124;
<a href="classawtk_1_1_emitter-members.html">所有成员列表</a>  </div>
  <div class="headertitle">
<div class="title">awtk.Emitter类 参考</div>  </div>
</div><!--header-->
<div class="contents">
<div class="dynheader">
类 awtk.Emitter 继承关系图:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classawtk_1_1_emitter.png" usemap="#awtk.Emitter_map" alt=""/>
  <map id="awtk.Emitter_map" name="awtk.Emitter_map">
<area href="classawtk_1_1_object.html" alt="awtk.Object" shape="rect" coords="192,56,310,80"/>
<area href="classawtk_1_1_idle_info.html" alt="awtk.IdleInfo" shape="rect" coords="0,112,118,136"/>
<area href="classawtk_1_1_object_array.html" alt="awtk.ObjectArray" shape="rect" coords="128,112,246,136"/>
<area href="classawtk_1_1_object_default.html" alt="awtk.ObjectDefault" shape="rect" coords="256,112,374,136"/>
<area href="classawtk_1_1_timer_info.html" alt="awtk.TimerInfo" shape="rect" coords="384,112,502,136"/>
</map>
 </div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public 成员函数</h2></td></tr>
<tr class="memitem:a127e92f885ea2e5229d4ff57935d1141"><td class="memItemLeft" align="right" valign="top"><a id="a127e92f885ea2e5229d4ff57935d1141"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>Emitter</b> (long nativeObj)</td></tr>
<tr class="separator:a127e92f885ea2e5229d4ff57935d1141"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab61a569bfceb776706c3213c88a1c93d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="enumawtk_1_1_ret.html">Ret</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classawtk_1_1_emitter.html#ab61a569bfceb776706c3213c88a1c93d">dispatch</a> (<a class="el" href="classawtk_1_1_event.html">Event</a> e)</td></tr>
<tr class="separator:ab61a569bfceb776706c3213c88a1c93d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6f20f6fe7d7e89cecda77b6fa96bebba"><td class="memItemLeft" align="right" valign="top"><a class="el" href="enumawtk_1_1_ret.html">Ret</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classawtk_1_1_emitter.html#a6f20f6fe7d7e89cecda77b6fa96bebba">dispatchSimpleEvent</a> (<a class="el" href="enumawtk_1_1_event_type.html">EventType</a> type)</td></tr>
<tr class="separator:a6f20f6fe7d7e89cecda77b6fa96bebba"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9d8fa91ae6c39399a4dac3a74b8bcd6b"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classawtk_1_1_emitter.html#a9d8fa91ae6c39399a4dac3a74b8bcd6b">on</a> (<a class="el" href="enumawtk_1_1_event_type.html">EventType</a> type, OnEvent on_event, long ctx)</td></tr>
<tr class="separator:a9d8fa91ae6c39399a4dac3a74b8bcd6b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af885c03791ed2d7bd6591046b7666849"><td class="memItemLeft" align="right" valign="top"><a class="el" href="enumawtk_1_1_ret.html">Ret</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classawtk_1_1_emitter.html#af885c03791ed2d7bd6591046b7666849">off</a> (int id)</td></tr>
<tr class="separator:af885c03791ed2d7bd6591046b7666849"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a81be2b3c03fc6b19bb53c4c0692403cb"><td class="memItemLeft" align="right" valign="top"><a class="el" href="enumawtk_1_1_ret.html">Ret</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classawtk_1_1_emitter.html#a81be2b3c03fc6b19bb53c4c0692403cb">enable</a> ()</td></tr>
<tr class="separator:a81be2b3c03fc6b19bb53c4c0692403cb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac43b0642e3099a0e7bf9ce651a73801c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="enumawtk_1_1_ret.html">Ret</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classawtk_1_1_emitter.html#ac43b0642e3099a0e7bf9ce651a73801c">disable</a> ()</td></tr>
<tr class="separator:ac43b0642e3099a0e7bf9ce651a73801c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1ca03ae015fb3252949a8c1d2b8df22d"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classawtk_1_1_emitter.html#a1ca03ae015fb3252949a8c1d2b8df22d">size</a> ()</td></tr>
<tr class="separator:a1ca03ae015fb3252949a8c1d2b8df22d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af369c5be623ad073173108c43e9650f1"><td class="memItemLeft" align="right" valign="top"><a class="el" href="enumawtk_1_1_ret.html">Ret</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classawtk_1_1_emitter.html#af369c5be623ad073173108c43e9650f1">destroy</a> ()</td></tr>
<tr class="separator:af369c5be623ad073173108c43e9650f1"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
静态 Public 成员函数</h2></td></tr>
<tr class="memitem:a748926f78dc5a8fa1b794454b926f684"><td class="memItemLeft" align="right" valign="top"><a id="a748926f78dc5a8fa1b794454b926f684"></a>
static <a class="el" href="classawtk_1_1_emitter.html">Emitter</a>&#160;</td><td class="memItemRight" valign="bottom"><b>cast</b> (long nativeObj)</td></tr>
<tr class="separator:a748926f78dc5a8fa1b794454b926f684"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4980fcb5f12dbe91eca3cbe19c648f72"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classawtk_1_1_emitter.html">Emitter</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classawtk_1_1_emitter.html#a4980fcb5f12dbe91eca3cbe19c648f72">create</a> ()</td></tr>
<tr class="separator:a4980fcb5f12dbe91eca3cbe19c648f72"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab1c262dec54716880936f6700f14adfa"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classawtk_1_1_emitter.html">Emitter</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classawtk_1_1_emitter.html#ab1c262dec54716880936f6700f14adfa">cast</a> (<a class="el" href="classawtk_1_1_emitter.html">Emitter</a> emitter)</td></tr>
<tr class="separator:ab1c262dec54716880936f6700f14adfa"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-attribs"></a>
Public 属性</h2></td></tr>
<tr class="memitem:a840c87a5d7ee53e5719a9228a52df909"><td class="memItemLeft" align="right" valign="top"><a id="a840c87a5d7ee53e5719a9228a52df909"></a>
long&#160;</td><td class="memItemRight" valign="bottom"><b>nativeObj</b></td></tr>
<tr class="separator:a840c87a5d7ee53e5719a9228a52df909"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<div class="textblock"><p>事件分发器, 用于实现观察者模式。 </p>
</div><h2 class="groupheader">成员函数说明</h2>
<a id="ab1c262dec54716880936f6700f14adfa"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab1c262dec54716880936f6700f14adfa">&#9670;&nbsp;</a></span>cast()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static <a class="el" href="classawtk_1_1_emitter.html">Emitter</a> awtk.Emitter.cast </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classawtk_1_1_emitter.html">Emitter</a>&#160;</td>
          <td class="paramname"><em>emitter</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>转换为emitter对象(供脚本语言使用)。</p>
<p>主要给脚本语言使用。</p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">emitter</td><td>emitter对象。</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>对象。 </dd></dl>

</div>
</div>
<a id="a4980fcb5f12dbe91eca3cbe19c648f72"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4980fcb5f12dbe91eca3cbe19c648f72">&#9670;&nbsp;</a></span>create()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static <a class="el" href="classawtk_1_1_emitter.html">Emitter</a> awtk.Emitter.create </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>创建emitter对象。</p>
<dl class="section return"><dt>返回</dt><dd>对象。 </dd></dl>

</div>
</div>
<a id="af369c5be623ad073173108c43e9650f1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af369c5be623ad073173108c43e9650f1">&#9670;&nbsp;</a></span>destroy()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="enumawtk_1_1_ret.html">Ret</a> awtk.Emitter.destroy </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>销毁。</p>
<dl class="section return"><dt>返回</dt><dd>返回RET_OK表示成功，否则表示失败。 </dd></dl>

</div>
</div>
<a id="ac43b0642e3099a0e7bf9ce651a73801c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac43b0642e3099a0e7bf9ce651a73801c">&#9670;&nbsp;</a></span>disable()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="enumawtk_1_1_ret.html">Ret</a> awtk.Emitter.disable </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>禁用。</p>
<p>禁用后emitter_dispatch无效，但可以注册和注销。</p>
<dl class="section return"><dt>返回</dt><dd>返回RET_OK表示成功，否则表示失败。 </dd></dl>

</div>
</div>
<a id="ab61a569bfceb776706c3213c88a1c93d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab61a569bfceb776706c3213c88a1c93d">&#9670;&nbsp;</a></span>dispatch()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="enumawtk_1_1_ret.html">Ret</a> awtk.Emitter.dispatch </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classawtk_1_1_event.html">Event</a>&#160;</td>
          <td class="paramname"><em>e</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>分发事件。如果当前分发的回调函数返回RET_REMOVE，该回调函数将被移出。 禁用状态下，本函数不做任何事情。</p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">e</td><td>事件对象。</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>如果当前分发的回调函数返回RET_STOP，dispatch中断分发，并返回RET_STOP，否则返回RET_OK。 </dd></dl>

</div>
</div>
<a id="a6f20f6fe7d7e89cecda77b6fa96bebba"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6f20f6fe7d7e89cecda77b6fa96bebba">&#9670;&nbsp;</a></span>dispatchSimpleEvent()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="enumawtk_1_1_ret.html">Ret</a> awtk.Emitter.dispatchSimpleEvent </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="enumawtk_1_1_event_type.html">EventType</a>&#160;</td>
          <td class="paramname"><em>type</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>分发事件。 对emitter_dispatch的包装，分发一个简单的事件。 如果当前分发的回调函数返回RET_STOP，dispatch中断分发，并返回RET_STOP，否则返回RET_OK。</p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">type</td><td>事件类型。</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd></dd></dl>

</div>
</div>
<a id="a81be2b3c03fc6b19bb53c4c0692403cb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a81be2b3c03fc6b19bb53c4c0692403cb">&#9670;&nbsp;</a></span>enable()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="enumawtk_1_1_ret.html">Ret</a> awtk.Emitter.enable </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>启用。</p>
<dl class="section return"><dt>返回</dt><dd>返回RET_OK表示成功，否则表示失败。 </dd></dl>

</div>
</div>
<a id="af885c03791ed2d7bd6591046b7666849"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af885c03791ed2d7bd6591046b7666849">&#9670;&nbsp;</a></span>off()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="enumawtk_1_1_ret.html">Ret</a> awtk.Emitter.off </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>注销指定事件的处理函数。</p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">id</td><td>emitter_on返回的ID。</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>返回RET_OK表示成功，否则表示失败。 </dd></dl>

</div>
</div>
<a id="a9d8fa91ae6c39399a4dac3a74b8bcd6b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9d8fa91ae6c39399a4dac3a74b8bcd6b">&#9670;&nbsp;</a></span>on()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int awtk.Emitter.on </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="enumawtk_1_1_event_type.html">EventType</a>&#160;</td>
          <td class="paramname"><em>type</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">OnEvent&#160;</td>
          <td class="paramname"><em>on_event</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long&#160;</td>
          <td class="paramname"><em>ctx</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>注册指定事件的处理函数。</p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">type</td><td>事件类型。 </td></tr>
    <tr><td class="paramname">on_event</td><td>事件处理函数。 </td></tr>
    <tr><td class="paramname">ctx</td><td>事件处理函数上下文。</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>返回id，用于emitter_off。 </dd></dl>

</div>
</div>
<a id="a1ca03ae015fb3252949a8c1d2b8df22d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1ca03ae015fb3252949a8c1d2b8df22d">&#9670;&nbsp;</a></span>size()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int awtk.Emitter.size </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>获取注册的回调函数个数，主要用于辅助测试。</p>
<dl class="section return"><dt>返回</dt><dd>回调函数个数。 </dd></dl>

</div>
</div>
<hr/>该类的文档由以下文件生成:<ul>
<li>output/Emitter.java</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者 &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
